<template>
	<view>
		<scroll-view scroll-x class="bg-white nav">
			<view class="header flex text-center">
				<button @tap="GetNewOrderNo(false)">创建新单</button>
				<button @tap="sureClear">清空单据</button>
				<button @tap="lookOrder()">查询单据</button>
				<button @tap="isChangeOrder()" v-if="!isChange">提交单据</button>
				<button @tap="isChangeOrder()" v-if="isChange">修改单据</button>
			</view> 
			<view class="main">
				<view class="main-box">
					<form>
						<view v-if="TabCur ==0" class="cg-main">
							<view  class="tabHeader" :class="isLookHeaderMore?'tabHeaderMore':''">
								<view class="cu-form-group">
									<view class="title">*单据编号:</view>
									<input class="inpt" disabled="true" name="input" :value="BillNo" placeholder="创建新单获取单号" ></input>
								</view>
								
								<view class="cu-form-group">
									<view class="title">*单据日期:</view>
									<!-- <view @tap="open()" class="inpt1">
										<input disabled="true" :value="BillDate"></input>
									</view> -->
									<picker mode="date" :value="BillDate" @change="DateChange">
										<view class="picker">
											{{BillDate}}
										</view>
									</picker>
								</view>
								
								<view v-if='BillType!=8&&BillType!=9'>
									<view class="cu-form-group" v-if='BillType==2||BillType==3'>
										<view class="title">*供&nbsp;应&nbsp;商&nbsp;:</view>
										<view class="inpt1"><input type="text" placeholder="点击获取" :value="SelectClientObj.ClientName" disabled="true"
											 style="text-align: left;" @tap="AddClientListen()" /></view>
									</view>
									<view class="cu-form-group" v-else>
										<view class="title">*客&emsp;&nbsp;&nbsp;户&nbsp;:</view>
										<view class="inpt1"><input type="text" placeholder="点击获取" :value="SelectClientObj.ClientName" disabled="true"
											 style="text-align: left;" @tap="AddClientListen()" /></view>
									</view>
								</view>
								<view class="cu-form-group">
									<view class="title">*仓&emsp;&nbsp;&nbsp;库&nbsp;:</view>
									<view class="inpt1"><input type="text" placeholder="点击获取" :value="SelectStoreObj.StoreName" disabled="true"
										 style="text-align: left;" data-target="StoreModal" @tap="showModal" />
										<view class="cu-modal" :class="modalName=='StoreModal'?'show':''">
											<view class="cu-dialog">
												<view class="cu-bar bg-white justify-end">
													<view class="content">请选择仓库</view>
													<view class="action" @tap="hideModal">
														<text class="cuIcon-close text-red"></text>
													</view>
												</view>
												<view class="padding-xl">
													<view class="searchStore">
														<input placeholder="请输入仓库名称" v-model="SearchStoreName" @input="filterStore"/>
														<button @tap="searchStore">搜索</button>
													</view>
													<view class="StoreListWrap">
														<view v-for="(item,index) in TempStoreList" :key="item.StoreID" @tap="selectStore(index)">{{item.StoreName}}</view>
													</view>
												</view>
											</view>
										</view>
									</view>
								</view>

								<view class="cu-form-group">
									<view class="title">制&nbsp;单&nbsp;人&nbsp;:</view>
									<input class="inpt" disabled="true" name="input" :value="CreateName" ></input>
								</view>
								<view class="cu-form-group" v-if="BillType==2||BillType==5">
									<view class="title">本次付款:</view>
									<input class="inpt"  name="input" v-model="CollectAmount" ></input>
								</view>
								<view class="cu-form-group" v-if="BillType==2||BillType==5">
									<view class="title">抹零金额:</view>
									<input class="inpt" name="input" v-model="NoSmallAmount" ></input>
								</view>
								
								<view class="cu-form-group" v-if="BillType==5">
									<view class="title">银行账号:</view>
									<view class="inpt1"><input type="text" placeholder="点击获取" :value="SelectBankObj.BankName" disabled="true"
										 style="text-align: left;" data-target="BankModal" @tap="showModal" />
										<view class="cu-modal" :class="modalName=='BankModal'?'show':''">
											<view class="cu-dialog">
												<view class="cu-bar bg-white justify-end">
													<view class="content">请选择账号</view>
													<view class="action" @tap="hideModal">
														<text class="cuIcon-close text-red"></text>
													</view>
												</view>
												<view class="padding-xl">
													<view class="searchStore">
														<input placeholder="请输入银行名称" v-model="SearchBankName" />
														<button @tap="searchBank">搜索</button>
													</view>
													<view class="StoreListWrap">
														<view v-for="(item,index) in BankList" :key="item.BankID" @tap="selectBank(index)">{{item.BankName}}</view>
													</view>
												</view>
											</view>
										</view>
									</view>
								</view>
								<view class="cu-form-group" v-if="BillType==5">
									<view class="title">收款方式:</view>
									<view class="inpt1"><input type="text" placeholder="点击获取" :value="SelectPayForWayObj.name" disabled="true"
										 style="text-align: left;" data-target="PayWayModal" @tap="showModal" />
										<view class="cu-modal" :class="modalName=='PayWayModal'?'show':''">
											<view class="cu-dialog">
												<view class="cu-bar bg-white justify-end">
													<view class="content">请选择收款方式</view>
													<view class="action" @tap="hideModal">
														<text class="cuIcon-close text-red"></text>
													</view>
												</view>
												<view class="padding-xl">
													<view class="searchStore">
														<input placeholder="请输入名称" v-model="SearchPayWayName" />
														<button @tap="searchPayWay">搜索</button>
													</view>
													<view class="StoreListWrap">
														<view v-for="(item,index) in PayForFs" :key="item.id" @tap="selectPayWay(index)">{{item.name}}</view>
													</view>
												</view>
											</view>
										</view>
									</view>
								</view>
								<view class="cu-form-group">
									<view class="title">业&nbsp;务&nbsp;员&nbsp;:</view>
									<view class="inpt1"><input type="text" placeholder="点击获取" :value="SelectOptionsObj.OperatorName" disabled="true"
										 style="text-align: left;" data-target="OptionsModal" @tap="showModal" />
										<view class="cu-modal" :class="modalName=='OptionsModal'?'show':''">
											<view class="cu-dialog">
												<view class="cu-bar bg-white justify-end">
													<view class="content">请选择业务员</view>
													<view class="action" @tap="hideModal">
														<text class="cuIcon-close text-red"></text>
													</view>
												</view>
												<view class="padding-xl">
													<view class="searchStore">
														<input placeholder="请输入业务员名称" v-model="SearchOptionName" @input="filterOption"/>
														<button @tap="searchOption">搜索</button>
													</view>
													<view class="StoreListWrap">
														<view v-for="(item,index) in TempOptionList" :key="item.OperatorID" @tap="selectOptions(index)">{{item.OperatorName}}</view>
													</view>
												</view>
											</view>
										</view>
									</view>
								</view>
								<view class="cu-form-group">
									<view class="title">备&emsp;&nbsp;&nbsp;注&nbsp;:</view>
									<input class="inpt" name="input" placeholder="点击修改" v-model="Comment"></input>
								</view>
								<view class="cu-form-group lookHeaderMore">
									<view class="title" style="width: 100%;text-align: center;" @tap="lookHeaderMore()">{{TbHeaderMore}}</view>
								</view>
							</view>
							<view>
								<view class="searchInput"> 
									<view class="goodFilter">
										<uniIcon type="search" size="14" style="line-height: 28px;margin-left: 5px;margin-right: 5px;color: #a7aab3;" /><input
										 placeholder="输入条码进行搜索" class="searchOption" confirm-type="search" type="text" @confirm="search()" v-model="searchKey"></input>
									</view>
									<view class="searchOptions">
										<button class="giveSong" @tap="gogoodlist()"></button>
										<button class="getPicture" @tap="tel()"></button>
									</view>
									
								</view>
								<view class="cu-modal" :class="modalName=='StoreScanGoodModal'?'show':''">
									<view class="cu-dialog">
										<view class="cu-bar bg-white justify-end">
											<view class="content">请选择商品</view>
											<view class="action" @tap="hideModal">
												<text class="cuIcon-close text-red"></text>
											</view>
										</view>
										<view class="padding-xl">
											<view class="GoodsListWrap">
												<view v-for="(item,index) in scanGoodList" :key="item.GoodsCode" @tap="selectGoodsList(index)">
												<image :src="unLoadimg" v-if="item.Goods_Image_Path1==''||item.Goods_Image_Path1=='underfind'" mode="aspectFill"></image>
												<image :src="item.Goods_Image_Path1" mode="aspectFill" v-else></image>
												<text>{{item.GoodsName}}</text>
												</view>
											</view>
										</view>
									</view>
								</view>
							</view>
							<view class="nowGoodCount"><view>商品数:{{OrderGoodsListLength}}</view>
							<view>商品总金额:<text class="red">￥{{goodAllAmount}}</text></view></view>
							<view class="detail-box">
								<view v-if="isSelectGood">
									<view class="cu-form-group">
										<view class="title">商品名称：</view>
										<input class="inpt" name="input">{{NowSelectGoods.GoodsName}}</input>
									</view>
									<view class="cu-form-group">
										<view class="title">编号：{{NowSelectGoods.GoodsName}}</view>
									</view>
									<view class="cu-form-group">
										<view class="title">赠品:</view>
										<picker @change="PickerChange5" :value="index5" :range="picker5">
											<view class="picker">
												{{index5>-1?picker5[index5]:'点击选择'}}
											</view>
										</picker>
									</view>
									<view class="cu-form-group">
										<view class="title">生产日期：</view>
										<view @tap="open1()" class="inpt1">
											<input disabled="true">{{ProductionDate.fulldate}}</input>
										</view>
									</view>
									<view class="cu-form-group">
										<view class="title">有效日期：</view>
										<view @tap="open2()" class="inpt1">
											<input disabled="true">{{ValidityDate.fulldate}}</input>
										</view>
									</view>
									<view class="cu-form-group">
										<view class="title">仓库：</view>
										<picker @change="PickerChange3" :value="index3+''" :range="picker3">
											<view class="picker">
												{{index3>-1?picker3[index3]:'点击选择'}}
											</view>
										</picker>
								</view>
								<view class="cu-form-group">
									<view class="title">单价：{{NowSelectGoods.PFPrice}}</view>
								</view>
								<view class="cu-form-group">
									<view class="title">单位：</view>
									<input class="inpt" name="input" disabled="true" :value="NowSelectGoods.UnitName"></input>
								</view>
								<view class="cu-form-group">
									<view class="title">数量：</view>
									<input class="inpt" name="input" placeholder="点击修改" v-model="GoodsQty"></input>
								</view>
								<view class="cu-form-group">
									<view class="title">折扣：</view>
									<input class="inpt" name="input" placeholder="点击修改" v-model="GoodsDiscount"></input>
								</view>
								<view class="cu-form-group">
									<view class="title">税率：</view>
									<input class="inpt" name="input" placeholder="点击修改" v-model="Tax"></input>
								</view>
								<view class="cu-form-group">
									<view class="title">库存：</view>
									<input class="inpt" name="input" disabled="true" :value="NowSelectGoods.stockqty+''"></input>
								</view>
								<view class="cu-form-group">
									<view class="title">批号：</view>
									<input class="inpt" name="input" disabled="item.IsBatch"></input>
									<!-- <button class="cu-btn  stop text-white" @tap="gopici">查询</button> -->
								</view>
								<view class="cu-form-group">
									<view class="title">规格：</view>
									<input class="inpt" name="input" disabled="item.Spec"></input>
									<!-- <button class="cu-btn  stop text-white" @tap="gopici">查询</button> -->
								</view>
								<view class="cu-form-group">
									<view class="title">备注：</view>
									<textarea class="inpt" name="input" placeholder="点击修改" v-model="GoodsRemark" ></textarea>
								</view>
							</view>
						</view>
						<!--商品明细列表-->
						<addOrderList :OrderGoodsList='OrderGoodsList' @deleteSelectGood='deleteSelectGood' @changeInfo='changeInfo' v-if="!isChangeShow"></addOrderList>
						<selectSimple :OrderGoodsList="OrderGoodsList" @deleteSelectGood="deleteSelectGood" @changeInfo="changeInfo"  v-else></selectSimple>
				</view>
				</form>
			</view>
	</view>
	</scroll-view>
	<view class="quiteTop" v-if="isShowTip" @tap="scrollTop">返回</br>顶部</view>
	<!--单位弹窗-->
	<!-- <goodModel :title="选择商品" @hideModal="@hideModal"></goodModel> -->
	<view class="cu-modal" :class="isShowScanModel?'show':''">
		<view class="cu-dialog ls-main">
			<view class="cu-bar bg-ls justify-between">
				<view class="action">
					<view class="cuIcon-info text-white" v-show="false"></view>
				</view>
				<view class="content text-white">选择商品</view>
				<view class="action" @tap="hideModal">
					<text class="cuIcon-close text-white"></text>
				</view>
			</view>
			<view class="padding text-left bg-white ls-contain">
				<scroll-view scroll-y style="height: 400px;padding-bottom: 100px">
					<view class="ls-box" @tap="choosesGoods(index)" v-for="(item,index) in scanGoodList" :key='index' :data-index="index">
						<!-- <view class="text-black">数据库：</view> -->
						<view>{{item.GoodsName}}</view>
					</view>
				</scroll-view>
			</view>
		</view>
	</view>
	<view class="chooseOtherGoodModel" v-show="false">
		<view class="MpdelContain">
			<view class="modelTitle">选择商品</view>
			<view class="modelContain">
				<radio-group @change="radioChange">
					<label class="uni-list-cell uni-list-cell-pd modelItem" v-for="(item, index) in scanGoodList" :key="item.value"
					 data-index="index">
						<view>
							<radio :value="index+''" :checked="index == current" />
						</view>
						<view>{{item.GoodsName}}</view>
					</label>
				</radio-group>
			</view>
		</view>
	</view>
	<uni-calendar ref="calendar" :insert="false" @confirm="confirm" />
	<uni-calendar ref="calendar1" :insert="false" @confirm="confirm1" />
	<uni-calendar ref="calendar2" :insert="false" @confirm="confirm2" />
	<settingOption :settingObj="'setting'+BillType" :modalName="modalName"
	 @changeSetting="changeSetting" @ycDy="ycDy" @djSh="djSh" @PrintOrder="PrintOrder" @hideModal="hideModal" :modalNames="modalNames" @radioChange="radioChange"
	ref="settingOption" @changeSelectShow="changeSelectShow" @xpDy="xpDy" ></settingOption>
	</view>
</template>
<script src="./js/add-order-rk-ck.js">
	
</script>

<style scoped>
	@import url("./css/add-order-rk-ck.css");
</style>
